﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using com.lover.astd.common.config;
using com.lover.astd.common.model;
using com.lover.astd.common.model.enumer;
using com.lover.astd.common;

namespace com.lover.astd.game.ui.server.impl.activities
{
    /// <summary>
    /// 犒赏事件, 粽子
    /// </summary>
    class GiftEventServer : LogicServer
    {
        public GiftEventServer(MainForm frm) { _mainForm = frm; ServerName = ConfigStrings.S_GiftEvent; ServerReadableName = ConfigStrings.SR_GiftEvent; }
        public override void renderSettings()
        {
            MainForm frm = _mainForm;
            Dictionary<string, string> conf = getConfig(ServerName);
            frm.chk_giftevent_enable.Checked = conf.ContainsKey(ConfigStrings.enabled) && conf[ConfigStrings.enabled].ToLower().Equals("true");
            if (conf.ContainsKey(ConfigStrings.serial))
            {
                frm.txt_giftevent_serial.Text = conf[ConfigStrings.serial];
            }
            else
            {
                frm.txt_giftevent_serial.Text = "231";
            }
        }
        public override void saveSettings()
        {
            MainForm frm = _mainForm;
            GameConfig conf = getConfig();
            conf.setConfig(ServerName, ConfigStrings.enabled, frm.chk_giftevent_enable.Checked.ToString());
            string serial = frm.txt_giftevent_serial.Text.Trim();
            conf.setConfig(ServerName, ConfigStrings.serial, serial);
        }
        public override void loadDefaultSettings()
        {
            GameConfig conf = getConfig();
            conf.setConfig(ServerName, ConfigStrings.enabled, "true");
            conf.setConfig(ServerName, ConfigStrings.serial, "231");
            renderSettings();
        }
    }
}
